﻿/**	@file		import_ctrl.h
 *	@date		(2007-03-13 23:35:29)/(2008-01-13 14:27:38)
 *-----------------------------------------------------------------------------
 *	\brief		DLL 等模块的导入管理器.
 *	@version	1.0.1.4
 *	@author		Nick Shallery	(nicknide@gmail.com)
 *	@copyright	YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.
 *-----------------------------------------------------------------------------
**/

#if			!defined(__LOLIX__LOLI__IMPORT_CTRL__K_IN_G__)
#define		__LOLIX__LOLI__IMPORT_CTRL__K_IN_G__
//==============================================================================
//--------------------------------------------------------------------------

#if			!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)
	#include	"../lolix_macro.h"
#endif	//	!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
	#include	"../lolix_type.h"
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)

namespace lolix{namespace loli{
	class import_handle;
	class import_factory;
}}

class LOLIX_NO_VTABLE lolix::loli::import_factory
	: public lolix::itf
{
public:
	LOLIX_DECLARE_ITF(lolix::loli::import_factory, lolix::itf, (0x05f2dd6c, 0x48124070, 0x8bbc245b, 0xfab11d8a));
	LOLIX_INTERFACE(create_inst, LOLIX_RETNV, (import_handle** out_ptr, const lx_wchar* const inst_name));
	LOLIX_INTERFACE(create_inst_with_module, LOLIX_RETNV, (import_handle** out_ptr, const void* const model_handle));
};


class LOLIX_NO_VTABLE lolix::loli::import_handle
	: public lolix::itf
{
public:
	LOLIX_DECLARE_ITF(lolix::loli::import_handle, lolix::itf, (0x35114a48, 0x7b6f4073, 0x8ad1cbef, 0xd1ac8dac));

	class LOLIX_NO_VTABLE call_back	//	no inherit from itf
	{
	public:
		virtual	LOLIX_RETNV	LOLIX_CALL_THROWS	get_proc(LOLIX_RETNV, void* proc) = 0;
		friend import_handle;
	};

	LOLIX_INTERFACE(get_proc	, LOLIX_RETNV	, (void**, const char* const proc_name));

	LOLIX_INLINE_CALL LOLIX_RETNV get_proc(char const * const proc_name, call_back* cb)
	{
		void* out;
		LOLIX_RETNV err = this->get_proc(&out, proc_name);
		return cb->get_proc(err, out);
	}
};




//--------------------------------------------------------------------------
//==============================================================================
#endif	//	!defined(__LOLIX__LOLI__IMPORT_CTRL__K_IN_G__)
